﻿package classes 
{
	import alternativa.engine3d.core.Object3D;
	import alternativa.engine3d.materials.FillMaterial;
	import alternativa.engine3d.primitives.Cone;
	import alternativa.utils.MathUtils;
	
	import alternativa.engine3d.events.MouseEvent3D;
	
	public class showAxis3D extends Object3D
	{
		public var ejeX:Cone;
		public var ejeY:Cone;
		public var ejeZ:Cone;
		
		public var obj3d:Object3D;
		
		public function showAxis3D(xLength:Number=100, yLength:Number=100, zLength:Number=100):void
		{
			obj3d = new Object3D();
			
			// Cone(height:Number = 100, bottomRadius:Number = 100, topRadius:Number = 0, heightSegments:uint = 1, radialSegments:uint = 12, reverse:Boolean = false, triangulate:Boolean = false)
			ejeX = new Cone(xLength,2,2,1,4,false,false);
			ejeY = new Cone(yLength,2,2,1,4,false,false);
			ejeZ = new Cone(zLength, 2, 2, 1, 4, false, false);
			
			//ejeX.cloneMaterialToAllSurfaces(new WireMaterial(1, 0xFF0000));
			//ejeY.cloneMaterialToAllSurfaces(new WireMaterial(1, 0x00FF00));
			//ejeZ.cloneMaterialToAllSurfaces(new WireMaterial(1, 0x0000FF));
			
			ejeX.cloneMaterialToAllSurfaces(new FillMaterial(0xFF0000));
			ejeY.cloneMaterialToAllSurfaces(new FillMaterial(0x00FF00));
			ejeZ.cloneMaterialToAllSurfaces(new FillMaterial(0x0000FF));

			ejeX.x=0; ejeX.y=0; ejeX.z=0;
			ejeY.x=0; ejeY.y=0; ejeY.z=0;
			ejeZ.x=0; ejeZ.y=0; ejeZ.z=0;
			
			ejeX.rotationY = MathUtils.toRadian(-90);
			ejeY.rotationX = MathUtils.toRadian(90);;
			
			obj3d.addChild(ejeX);
			obj3d.addChild(ejeY);
			obj3d.addChild(ejeZ);
			
			ejeX.addEventListener(MouseEvent3D.CLICK, function(e:MouseEvent3D):void { trace(e.target); } );
			ejeY.addEventListener(MouseEvent3D.CLICK, function(e:MouseEvent3D):void { trace(e.target); } );
			ejeZ.addEventListener(MouseEvent3D.CLICK, function(e:MouseEvent3D):void { trace(e.target); } );
			
			addChild(obj3d);
		}
		
	}

}